<?php
class Site_Model_ShoppingCart
{
	protected static $_instance = null;
	
	private $itens;
	private $totalItens;
	
	private function __construct()
	{
		$this->itens = new Zend_Session_Namespace();
	}
	
	public static function get_instance()
	{
		if (null === self::$_instance)
		{
			self::$_instance = new self();
		}
	
		return self::$_instance;
	}
	
	public function getItens()
	{
		return $this->itens->product;
	}
	
	public function add($product, $size)
	{
		$index = rand(100001,999999);
		$this->itens->product[ $index ]['cart'] = $product;
		$this->itens->product[ $index ]['size'] = $size;
	}
	
	public function remove($key)
	{
		unset( $this->itens->product[ $key ] );
	}
	
	public function getTotalItens()
	{
		return count( $this->itens->product );
	}
}

